import axios from "axios";
import React, {useEffect, useState} from 'react';
import {Button, List} from 'antd';
import "./UpdateList.css"
import {Link} from 'react-router-dom';
import config from '../utils/config'

function UpdateList() {
    const [courts, setCourts] = useState([]);

    useEffect(() => {
        axios.get(`${config.serverDomain}tmadmin/courts/update`)
            .then(res => setCourts(res.data.updatingCourts))
            .catch(res => window.alert("系统错误"))
    }, [])

    return <div>
        <h1>修改球场申请列表</h1>
        <List
            dataSource={courts}
            renderItem={(court) => (
                <List.Item>
                    {court.name}
                    <Link to={`/courts/update/${court.id}`}>
                        <Button type="primary" shape="round" className="operate-btn">查看</Button>
                    </Link>
                </List.Item>
            )}/>
    </div>
}

export default UpdateList;
